﻿@{
    ViewBag.Title = "我支持的项目";
    Layout = "~/Views/Shared/_LayoutFore.cshtml";
}
<link href="~/Scripts/laypage/skin/laypage.css" rel="stylesheet" />
<div class="RightContrent">
    <div style="margin-left: 50px; margin-right: 50px;">
        <div class="tab-content">
            <div class="line10"></div>
            <div class="line10"></div>
            <div class="tab_title">@ViewBag.Title</div>
            <div class="tab-content">
                <div style="width: 16px; height: 12px; float: left;">
                    <img src="~/Content/Images/leftarraw.png" />
                </div>
            </div>

            <div class="tab-content_border">
                <div class="u-center">
                    @* <form id="formQuery" action="@Url.Action("SecondProject")" class="form-inline" role="form" method="POST">
                        $1$ <input type="hidden" name="PayStatus" id="PayStatus" />#1#
                    </form>*@

                    <div class="menu-list">
                        <div class="ui-tab clearfix" id="group">
                            <a onclick="LoadData(1, '')" class="ui-tab-list ui-tab-list--now" href="javascript:void(0)">全部</a>
                            <a onclick="LoadData(1, 0)" class="ui-tab-list" href="javascript:void(0)">等待付款</a>
                            <a onclick="LoadData(1, 1)" class="ui-tab-list" href="javascript:void(0)">付款成功</a>
                            <a onclick="LoadData(1, 9)" class="ui-tab-list" href="javascript:void(0)">交易完成</a>
                            <a onclick="LoadData(1, 10)" class="ui-tab-list" href="javascript:void(0)">交易关闭</a>
                            <a onclick="LoadData(1, 6)" class="ui-tab-list" href="javascript:void(0)">退款成功</a>
                        </div>
                    </div>

                    <div class="line10"></div>
                    <div id="gridlist" class="xjgrid">
                        <div class="grid-body">
                            <div class="grid-body-inner">
                                <table id="gridlist_detail">
                                    <thead>
                                        <tr class="thead">
                                            <td style="width: 15%" class="sortable">
                                                <div style="text-align: left;">项目信息</div>
                                            </td>
                                            <td style="width: 45%" class="sortable"></td>
                                            <td style="width: 15%" class="sortable">
                                                <div style="text-align: left;">实付款（元）</div>
                                            </td>
                                            <td style="width: 15%">
                                                <div style="text-align: center;">交易状态</div>
                                            </td>
                                            <td style="width: 10%">
                                                <div style="text-align: center;">操作</div>
                                            </td>
                                        </tr>
                                    </thead>
                                    <tbody class="DataList">
                                        <tr id="gridlist_tr_0" class="">
                                            <td>
                                                <a class="b-l-img ThumImage" target="_self"></a>
                                            </td>
                                            <td class="td-left">
                                                <div class="clearfix">
                                                    <a class="b-l-name" href="" data-bind="ProjectName" target="_self"></a>
                                                    <p class="b-l-tag-green" data-bind="ProjectStatusName"></p>
                                                    <br>
                                                    订单编号：
                                        <label data-bind="SerialNumber"></label>
                                                    <br />
                                                    <label data-bind="BiaoNo"></label>
                                                </div>
                                                <div class="b-l-info clearfix">
                                                    <div class="b-l-i-list">
                                                        <p>已完成</p>
                                                        <p class="size14" data-bind="ProjectPercent">
                                                            117%
                                                        </p>
                                                    </div>
                                                    <div class="b-l-i-list">
                                                        <p>已筹集</p>
                                                        <p class="size14" data-bind="CurrentAmount">¥0</p>
                                                    </div>
                                                    <div class="b-l-i-list">
                                                        <p>剩余时间</p>
                                                        <p class="size14" data-bind="RemainDays">0 天</p>
                                                    </div>
                                                </div>
                                            </td>
                                            <td>
                                                <p class="b-l-price-red " data-bind="ZCamount">1.00</p>
                                                <div>
                                                    (含运费:
                                            <span data-bind="ItemFreight"></span>)
                                                </div>
                                            </td>
                                            <td>
                                                <p class="font-grey1" data-bind="PayStatus"></p>
                                            </td>
                                            <td class="BianJi"></td>
                                        </tr>
                                    </tbody>
                                </table>
                                <input type="hidden" value="" id="check">
                            </div>
                            <div class="xjgrid-load" style="display: none;">
                                <img src="../../assets/layer/skin/default/xubox_loading2.gif">加载中...
                            </div>
                        </div>
                        <div id="gridlist_pagep" class="grid-pagination">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@section script{
    <script src="~/Scripts/laypage/laypage.js"></script>
    <script src="~/Scripts/transparency.min.js"></script>
    <script type="text/javascript">
        var options = {
            listUrl: "@Url.Action("SecondProject")"
        };

        var pages = 0;

        function LoadData(curr, paystatus) {
            var url = options.listUrl;
            $.ajax({
                url: url,
                type: 'Post',
                dataType: 'json',
                data: {
                    sortname: "Id",
                    sortorder: "DESC",
                    title: false,
                    rp: 5,
                    usepager: true,
                    page: curr,
                    showcheckbox: false,
                    PayStatus: paystatus
                },
                success: function (result) {
                    if (result.DataList == null)
                        return;
                    var post = result.DataList;
                    var directives = {
                        ThumImage: {
                            html: function () {
                                return "<img style='width: 100px; height: 100px' src='" + this.ProjectThumImage + "  '>";
                            },
                            href: function () {
                                return "@Url.Action("Detail", "Default")?Id=" + this.Id;
                            }
                        },
                        ProjectName: {
                            href: function () {
                                return "@Url.Action("Detail", "Default")?Id=" + this.Id;
                            }
                        },
                        AuditStatus: {
                            html: function () {
                                var html = "";
                                if (this.AuditStatus == 0) {
                                    html = "已保存";

                                } else if (this.AuditStatus > 109 && this.AuditStatus < 210) {
                                    html = "审核中";

                                } else if (this.AuditStatus == 210) {
                                    html = "众筹中";

                                } else if (this.AuditStatus == 109) {
                                    html = "不通过";

                                } else if (this.AuditStatus == 220) {
                                    html = "众筹成功";

                                } else if (this.AuditStatus == 219) {
                                    html = "众筹失败";
                                }
                                return html;
                                /*    switch (this.AuditStatus) {
                                        case 0:
                                            html = "已保存";
                                            break;
                                        case 1:
                                            html = "审核中";
                                            break;
                                        case 210:
                                            html = "众筹中";
                                            break;
                                        case 3:
                                            html = "不通过";
                                            break;
                                        case 4:
                                            html = "已结束";
                                            break;
                                        case 5:
                                            html = "已成功";
                                            break;
                                        case 6:
                                            html = "众筹失败";
                                            break;
                                        case -1:
                                            html = "已删除";
                                            break;
                                    }
                                    return html;*/
                            }
                        },
                        PayStatus: {
                            html: function () {
                                var html = "";
                                switch (this.PayStatus) {
                                    case 0:
                                        html = "<span style='color:red;'>等待付款</span>";
                                        break;
                                    case 1:
                                        html = "付款成功";
                                        break;
                                    case 2:
                                        html = "付款失败";
                                        break;
                                    case 3:
                                        html = "过期";
                                        break;
                                    case 4:
                                        html = "撤销成功";
                                        break;
                                    case 5:
                                        html = "退款中";
                                        break;
                                    case 6:
                                        html = "退款成功";
                                        break;
                                    case 7:
                                        html = "退款失败";
                                        break;
                                    case 8:
                                        html = "部分退款成功";
                                        break;
                                    case 9:
                                        html = "已收货";
                                        break;
                                    case 10:
                                        html = "交易关闭";
                                        break;
                                    case 11:
                                        html = "已完成";
                                        break;
                                }
                                return html;
                            }
                        },
                        BianJi: {
                            html: function () {

                                return this.BianJi;
                            }
                        },
                        BiaoNo: {
                            html: function () {
                                if (this.PayStatus == 1 || this.PayStatus == 3) {
                                    return "运单编号：" + this.BiaoNo;
                                } else {
                                    return "";
                                }
                            }
                        }
                    };
                    $('.DataList').render(post, directives);
                    if (result.TotalPage > 0) {
                        pages = result.TotalPage;
                    }
                    laypage({
                        cont: 'gridlist_pagep', //容器。值支持id名、原生dom对象，jquery对象。【如该容器为】：<div id="page1"></div>
                        pages: pages, //通过后台拿到的总页数
                        curr: result.PageIndex + 1, //当前页
                        jump: function (obj, first) { //触发分页后的回调
                            if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr  
                                LoadData(obj.curr, paystatus);
                            }
                        }
                    });
                }
            });
        }

        $(function () {
            LoadData(1, "");
            $("#group a").click(function () {
                $("#group a").removeClass("ui-tab-list--now");
                $(this).addClass("ui-tab-list--now");
            });

        });
        //取消订单

        function cancelOrder(id) {
            //收货地址主键ID
            // var addrID = $("#addrID").val();
            /* if (confirm('确定要取消订单吗？')) {
                 $.post("/UserOrder/CancelOrder?orderid=" + id, function (msg) {
                     location.href = location.href;
                 });
             }*/
            $.dialog.confirm('确定要取消订单吗？', function () {
                $.post("/UserOrder/CancelOrder?orderid=" + id, function (msg) {
                    location.href = location.href;
                });
            });

        }

        //删除订单

        function deleteOrder(id) {
            $.dialog.confirm('确定要删除该订单吗？', function () {
                $.post("/UserOrder/DeleteOrder?orderid=" + id, function (msg) {
                    location.href = location.href;
                });
            });
        }
    </script>
}





